#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void replaceSpace(char* str, int length)
{
	int spacecnt = 0;
	char* cur = str;
	while (*cur!='\0')
	{
		if (*cur == ' ')
			spacecnt++;
		cur++;
	}
	int newlen = length + spacecnt * 2;
	int end1 = length - 1;
	int end2 = newlen - 1;
	while (end1 != end2) {
		if(str[end1]!=' ')
		{
			str[end2--] = str[end1--];
		}
		else
		{
			str[end2--] = '0';
			str[end2--] = '2';
			str[end2--] = '%';
			end1--;
		}

	}

}
int main()
{
	char str[50] = "We Are Happy";
	replaceSpace(str,12);
	printf("%s\n", str);

	return 0;
}